
namespace Derm.Render.Shaders {

	/// <summary>
	/// Shader source generated from ProjectRigidVertex shader source file.
	/// </summary>
	public class ProjectRigidVertex : ShaderObject
	{
		#region Constructors

		/// <summary>
		/// Construct a ProjectRigidVertex defining itself a vertex shader.
		/// </summary>
		public ProjectRigidVertex() : base(Stage.Vertex, "Derm/Shaders/ProjectRigidVertex") { }

		/// <summary>
		/// A string that identifies this ShaderObject implementation in ShaderLibraryConfiguration.
		/// </summary>
		public static readonly string LibraryId = "Derm.Shaders.ProjectRigidVertex";

		#endregion

		#region ShaderObject Overrides

		/// <summary>
		/// The only stage that this ShaderObject can link.
		/// </summary>
		public static readonly Stage LibraryStage = Stage.Vertex;

		/// <summary>
		/// The source string read from Derm/Shaders/ProjectRigidVertex.
		/// </summary>
		protected override string[] Source { get { return (sShaderSource); } }

		/// <summary>
		/// The source string read from Derm/Shaders/ProjectRigidVertex.
		/// </summary>
		private static readonly string[] sShaderSource = new string[] {
			"",
			"//  Copyright (C) 2011-2012 Luca Piccioni",
			"// ",
			"//  This program is free software: you can redistribute it and/or modify",
			"//  it under the terms of the GNU General Public License as published by",
			"//  the Free Software Foundation, either version 3 of the License, or",
			"//  (at your option) any later version.",
			"// ",
			"//  This program is distributed in the hope that it will be useful,",
			"//  but WITHOUT ANY WARRANTY; without even the implied warranty of",
			"//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the",
			"//  GNU General Public License for more details.",
			"// ",
			"//  You should have received a copy of the GNU General Public License",
			"//  along with this program.  If not, see <http://www.gnu.org/licenses/>.",
			"",
			"#include </Derm/Shaders/TransformState>",
			"#include </Derm/Shaders/IProjectVertex>",
			"",
			"// Project vertex position",
			"vec4 ProjectVertexPosition(in vec4 v)",
			"{",
			"	return (ds_ModelProjection * v);",
			"}",
			"",
			"// Project vertex position",
			"vec4 ProjectVertexPosition(in vec3 v)",
			"{",
			"	return (ds_ModelProjection * vec4( v , 1.0 ) );",
			"}",
			"",
			"// Project vertex position",
			"vec4 ProjectVertexPosition(in vec2 v)",
			"{",
			"	return (ds_ModelProjection * vec4( v , 0.0, 1.0 ) );",
			"}",
			"",
			"// Project vertex normal",
			"vec3 ProjectVertexNormal(in vec3 n)",
			"{",
			"	return (ds_NormalMatrix * n);",
			"}",
			"",
		};

		#endregion
	}

	/// <summary>
	/// Shader include extracted from Compatibility.
	/// </summary>
	public class ShaderCompatibility : ShaderInclude
	{
		#region Constructors

		/// <summary>
		/// Construct a ShaderCompatibility.
		/// </summary>
		public ShaderCompatibility() : base("/Derm/Shaders/Compatibility", sShaderInclude) { }

		#endregion

		#region ShaderInclude Source Code

		/// <summary>
		/// The shader include source code.
		/// </summary>
		private static readonly string[] sShaderInclude = new string[] {
			"// - ATTRIBUTE: used to mark a vertex shader inputs\n",
			"// - SHADER_IN: used to mark a non-vertex shader inputs\n",
			"// - SHADER_OUT: used to mark a non-fragment shader output\n",
			"// - OUT: used to mark a fragment shader output\n",
			"#if __VERSION__ >= 130\n",
			"#define ATTRIBUTE in\n",
			"#define SHADER_IN in\n",
			"#define SHADER_OUT out\n",
			"#define OUT out\n",
			"#else\n",
			"#define ATTRIBUTE attribute\n",
			"#define SHADER_IN varying\n",
			"#define SHADER_OUT varying\n",
			"#define OUT\n",
			"#endif\n",
			"// - BEGIN_UNIFORM_BLOCK(blockname)\n",
			"// - END_UNIFORM_BLOCK()\n",
			"#if __VERSION__ >= 130\n",
			"#define BEGIN_UNIFORM_BLOCK(name)	uniform name {\n",
			"#define END_UNIFORM_BLOCK() };\n",
			"#else\n",
			"#define BEGIN_UNIFORM_BLOCK(name)\n",
			"#define END_UNIFORM_BLOCK()\n",
			"#endif\n",
			"// - BEGIN_INPUT_BLOCK(blockname)\n",
			"// - END_INPUT_BLOCK()\n",
			"// - BEGIN_OUTPUT_BLOCK(blockname)\n",
			"// - END_OUTPUT_BLOCK()\n",
			"#if __VERSION__ >= 150\n",
			"#define BEGIN_INPUT_BLOCK(name)	in name {\n",
			"#define END_INPUT_BLOCK() };\n",
			"#define BEGIN_OUTPUT_BLOCK(name) out name {\n",
			"#define END_OUTPUT_BLOCK() };\n",
			"#else\n",
			"#define BEGIN_INPUT_BLOCK(name)\n",
			"#define END_INPUT_BLOCK()\n",
			"#define BEGIN_OUTPUT_BLOCK(name)\n",
			"#define END_OUTPUT_BLOCK()\n",
			"#endif\n",
			"#if __VERSION__ >= 130\n",
			"#define TEXTURE_2D texture\n",
			"#else\n",
			"#define TEXTURE_2D texture2D\n",
			"#endif\n",
		};

		#endregion
	}

	/// <summary>
	/// Shader include extracted from TransformState.
	/// </summary>
	public class TransformState : ShaderInclude
	{
		#region Constructors

		/// <summary>
		/// Construct a TransformState.
		/// </summary>
		public TransformState() : base("/Derm/Shaders/TransformState", sShaderInclude) { }

		#endregion

		#region ShaderInclude Source Code

		/// <summary>
		/// The shader include source code.
		/// </summary>
		private static readonly string[] sShaderInclude = new string[] {
			"// Model view matrix\n",
			"uniform mat4 ds_Model;\n",
			"// Projection matrix\n",
			"uniform mat4 ds_Projection;\n",
			"// Product between Model and Projection matrix\n",
			"uniform mat4 ds_ModelProjection;\n",
			"// Normal transformation matrix\n",
			"uniform mat3 ds_NormalMatrix;\n",
		};

		#endregion
	}

	/// <summary>
	/// Shader include extracted from IProjectVertex.
	/// </summary>
	public class IProjectVertex : ShaderInclude
	{
		#region Constructors

		/// <summary>
		/// Construct a IProjectVertex.
		/// </summary>
		public IProjectVertex() : base("/Derm/Shaders/IProjectVertex", sShaderInclude) { }

		#endregion

		#region ShaderInclude Source Code

		/// <summary>
		/// The shader include source code.
		/// </summary>
		private static readonly string[] sShaderInclude = new string[] {
			"// Project vertex position\n",
			"vec4 ProjectVertexPosition(in vec4 v);\n",
			"// Project vertex position\n",
			"vec4 ProjectVertexPosition(in vec3 v);\n",
			"// Project vertex position\n",
			"vec4 ProjectVertexPosition(in vec2 v);\n",
			"// Project vertex normal\n",
			"vec3 ProjectVertexNormal(in vec3 n);\n",
		};

		#endregion
	}

}

